package com.kcs.dc.report.model.dao;

import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Types;

import com.kcs.common.utils.Constant;
import com.kcs.common.utils.LogWriter;

public class loginDAO {
	
	public boolean updateUserLogin(String user_id, String user_name, Connection conn) throws Exception {
		
		int num_record = 0;
		CallableStatement proc = null;
		
		try {
			proc = conn.prepareCall("{ call update_user_access_proc(?, ?, ?) }");
			proc.setString(1, user_id);
			proc.setString(2, user_name);	
			proc.registerOutParameter(3, Types.INTEGER);
			
			proc.execute();   
			conn.commit();
			
			num_record = proc.getInt(3);			
			LogWriter.debug("User ID :" + user_id + ", Return update success : " + num_record, Constant.LOGGER_APPLICATION);	
					
			
		} catch (Exception e) {
			LogWriter.error("1.1 loginDAO [Method : updateUserLogin call Store update_user_access_proc] : " + e.getMessage(), Constant.LOGGER_APPLICATION);
			throw new Exception();
		} finally {
			if (proc != null) {
				try {
					proc.close();
				} catch (SQLException e) {
					LogWriter.error("1.2 loginDAO [Method : updateUserLogin call Store update_user_access_proc] : " + e.getMessage(), Constant.LOGGER_APPLICATION);
					throw new Exception();
				}
			}		
		}
		return true; 
	}	
	
}
